<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <title>河长制—水道监测管理系统</title>
  <link href="{{asset(getThemeAssets('bootstrap/css/bootstrap.min.css', true))}}" rel="stylesheet">
  <link href="{{asset(getThemeAssets('font-awesome/css/font-awesome.min.css', true))}}" rel="stylesheet">
  <link href="{{asset(getThemeAssets('animate/animate.css', true))}}" rel="stylesheet">
  <link href="{{asset(getThemeAssets('css/style.css'))}}" rel="stylesheet">
  @yield('css')
</head>
<body class="">
  <div id="wrapper">
    @include('layouts.partials.'.getTheme().'-sidebar')

    <div id="page-wrapper" class="gray-bg">
      <div class="row border-bottom">
        <nav class="navbar navbar-static-top  " role="navigation" style="margin-bottom: 0">
          <div class="navbar-header">
              <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
          </div>
          <ul class="nav navbar-top-links navbar-right">
              <li>
                  <span class="m-r-sm text-muted welcome-message">当前用户,{{auth()->user()->name}}</span>
              </li>
              @if(haspermission('settingcontroller.language'))
              <li>
                <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#" aria-expanded="true">
                  <i class="fa fa-language text-warning"></i>
                  <span class="label label-warning">{{session('locale', config('app.fallback_locale'))}}</span>
                </a>
                <ul class="dropdown-menu dropdown-user">
                  <li>
                    <a href="{{url('admin/setting/zh')}}">{{trans('common.zh')}}</a>
                  </li>
                  <li>
                    <a href="{{url('admin/setting/en')}}">{{trans('common.en')}}</a>
                  </li>
                </ul>
              </li>
              @endif
              <li>
                <a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="true">
                  <i class="fa fa-tint fa-lg text-info"></i>
                </a>
                <ul class="dropdown-menu dropdown-user">
                  <li>
                    <a href="#"></a>
                  </li>
                </ul>
              </li>
              <li>
                  <a href="{{ url('logout') }}" onclick="event.preventDefault();document.getElementById('logout-form').submit();">
                      <i class="fa fa-sign-out"></i> {{trans('common.logout')}}
                      <form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">{{ csrf_field() }}</form>
                  </a>
              </li>
          </ul>
        </nav>
      </div>
      @yield('content')
      <div class="row">
      <div class="footer">
        <div class="pull-right">
         <strong></strong>
        </div>
        <div>
          <strong>Copyright &copy; JUST 计算机协会 2017 11月</strong>
        </div>
        <audio id="bgmusic">
            <source src="{{asset(getThemeAssets('music/4611.mp3'))}}" type="audio/mp3">
        </audio>
      </div>
      </div>
    </div>
  </div>
  <script src="{{asset(getThemeAssets('jquery/jquery-2.1.1.js', true))}}"></script>
  <script src="{{asset(getThemeAssets('bootstrap/js/bootstrap.min.js', true))}}"></script>
  <script src="{{asset(getThemeAssets('metisMenu/jquery.metisMenu.js', true))}}"></script>
  <script src="{{asset(getThemeAssets('slimscroll/jquery.slimscroll.min.js', true))}}"></script>
  <script src="{{asset(getThemeAssets('js/inspinia.js'))}}"></script>
  <script type="text/javascript">
      $(function () {
            // 定时刷新
            setTimeout(function () {
                    alltimedata();
                },
                100);//setTimeout 程序执行后200毫秒执行push，但是仅此一次。
            setInterval(function () {
                    alltimedata();
                },
                3000);
            // 利用ajax动态加载实时监测信息，实现定时及页面局部刷新
            function alltimedata() {
                $.ajax({
                    url: "{{url('admin/coring/alltimeinfo')}}",
                    data: {},
                    type: 'get',
                    datatype: 'json',
                    async: true,
                    // 跨域请求时同时发送自身cookie
                    xhrFields: {
                        withCredentials: true
                    },
                    crossDomain: true,
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                    },
                    success: function (data) {
                        var isAlarm = 0;
                        for(var i=0; i<data.length;i++) {
                            // alert(status[i].status);
                            if(data[i].status == 2) {
                                isAlarm = 1;
                            }      
                        }
                            if(isAlarm == 1) {
                            var audio = document.getElementById("bgmusic");
                            audio.play();                                  
                            }

                    }
                });
            }
    });
  </script>
  @yield('js')
</body>
</html>